﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace Core.Infrastructure.ErrorReportService
{
    public class DelegateErrorReportService : IErrorReportService
    {
        private Action<string> reportMessage;
        private Action<Exception> reportException;
        private Action<string, Exception> reportMessageException;

        public DelegateErrorReportService(Action<string> reportMessage,
                                          Action<Exception> reportException = null,
                                          Action<string, Exception> reportMessageException = null)
        {
            this.reportMessage = reportMessage;
            this.reportException = reportException;
            this.reportMessageException = reportMessageException;
        }

        public void Report(string message)
        {
            if (reportMessage != null)
            {
                reportMessage(message);
            }
            else
            {
                throw new NotSupportedException();
            }
        }

        public void Report(string message, Exception exception)
        {
            if (reportMessageException != null)
            {
                reportMessageException(message, exception);
            }
            else
            {
                throw new NotSupportedException();
            }
        }

        public void Report(Exception exception)
        {
            if (reportException != null)
            {
                reportException(exception);
            }
            else
            {
                throw new NotSupportedException();
            }
        }
    }
}
